# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=inkscape
pkgver=1.2
_pkgdate=2022-05-15
_pkgcommit=dc2aedaf03
pkgrel=2
pkgdesc="A vector-based drawing program - svg compliant"
url="https://inkscape.org/"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="
	boost-dev
	cmake
	dbus-dev
	double-conversion-dev
	gc-dev
	gdl-dev
	gsl-dev
	gtkmm3-dev
	gtkspell3-dev
	imagemagick6-dev
	lcms2-dev
	libcdr-dev
	libjpeg-turbo-dev
	libsoup-dev
	libtool
	libvisio-dev
	libxml2-dev
	libxslt-dev
	poppler-dev
	popt-dev
	potrace-dev
	python3-dev
	samurai
	ttf-dejavu
	"
depends="desktop-file-utils"
checkdepends="bash py3-lxml py3-numpy>=1.14.3-r1"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-lang $pkgname-view $pkgname-bash-completion"
source="https://media.inkscape.org/dl/resources/file/inkscape-$pkgver.tar.xz
	fix-Werror.patch
	"
options="!check" # cxxtest hangs at least on x86_64
builddir="$srcdir"/$pkgname-${pkgver}_${_pkgdate}_$_pkgcommit

build() {
	export CXXFLAGS="$CXXFLAGS -std=c++11"
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	PATH="$PATH:$PWD" ninja -C src check
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

view() {
	pkgdesc="Viewing program for SVG files"
	amove usr/bin/inkview
}

doc() {
	default_doc
	amove usr/share/inkscape/examples usr/share/inkscape/tutorials
}

sha512sums="
d4be4ef80638ed5a0fae655c3ea696a2171130110e220beb510e4b51dba95854ad065293bb07683c93a1c550764a1947621389da1199c43997f76b62b69e3812  inkscape-1.2.tar.xz
c687b71fb5f11f41c5a389850ae62e4e82c1e66ecc04bd782c31164312e9a8bded676a1948c3c7e8ff25246a74dacf5e6d61aa9be707c170712df82b33ea801e  fix-Werror.patch
"
